#!/usr/bin/env python3
#-*- coding:utf-8 -*-
'''class Student(object):
    def __init__(self,name,score):
        self.name=name
        self.score=score
        pass
    pass

if __name__=='__main__':
    stu=[]
    for i in range(3):
        name=input("name:")
        score=input("score:")
        stu.append(Student(name,score))
        pass
    print(stu[1].name)'''

#!/usr/bin/env python3
#-*- coding:utf-8 -*-
class Person(object):
    def __init__(self,name,fighting,reputation,officer,member,abilityNam,money):
        self.name=name
        self.fighting=fighting
        self.reputation=reputation
        self.officer=officer
        self.member=member
        self.abilityNam=abilityNam
        self.money=money
    pass

    def compute(self):
        self.money=0
        if int(self.fighting)>80 and int(self.abilityNam)>=1:
            self.money=self.money+8000
        if int(self.fighting)>85 and int(self.reputation)>80:
            self.money=self.money+4000
        if int(self.fighting)>90:
            self.money=self.money+2000
        if int(self.fighting)>85 and self.member=='Y':
            self.money=self.money+1000
        if int(self.reputation)>80 and self.officer=='Y':
            self.money=self.money+850
        pass
    pass

if __name__=='__main__':
    peo=[]
    N=int(raw_input())
    for i in range(N):
        name,fighting,reputation,officer,member,abilityNam=raw_input().split()
        peo.append(Person(name,fighting,reputation,officer,member,abilityNam,0))
        peo[i].compute()
    pass

    totalMoney=0
    temp=peo[0]
    for i in range(N):
        totalMoney=totalMoney+peo[i].money
        if temp.money<peo[i].money:
            temp=peo[i]
            pass
        pass

    print(temp.name)
    print(temp.money)
    print(totalMoney)


